//
//  Elastic.m
//  Zaker
//
//  Created by lirui on 16/3/15.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "Elastic.h"
#import "WXApi.h"

@interface Elastic ()

@end
@implementation Elastic

+(void)elastic:(NSString *)string
{
    
    NSArray *Objs = @[
                      [MenuLabel CreatelabelIconName:@"wechat" Title:@"微信"],
                      [MenuLabel CreatelabelIconName:@"pengyouquan" Title:@"朋友圈"],
//                      [MenuLabel CreatelabelIconName:@"qq" Title:@"QQ"],
//                      [MenuLabel CreatelabelIconName:@"qqkongjian" Title:@"QQZone"],
//                      [MenuLabel CreatelabelIconName:@"weibo" Title:@"微博"],
                      [MenuLabel CreatelabelIconName:nil Title:nil]
                      
                      ];
    
    [HyPopMenuView CreatingPopMenuObjectItmes:Objs TopView:nil OpenOrCloseAudioDictionary:nil SelectdCompletionBlock:^(MenuLabel *menuLabel, NSInteger index) {
        //        NSLog(@"index:%ld ItmeNmae:%@",index,menuLabel.title);
        Elastic *elastci = [[Elastic alloc] init];
        
        if (index == 0) {
            [elastci weixin:string];
            
        }else if (index == 1){
            [elastci penyouquan:string] ;
            
        }else if (index == 2){
//            [elastci QQliaotian:string];
            
        }else if (index == 3) {
        
//            [elastci qqkongjian:string];
        }else if (index == 4){
            
        }
    }];

}

- (void)weixin:(NSString *)str
{
    
    SendMessageToWXReq* req = [[SendMessageToWXReq alloc] init];
    req.text = str;
    req.bText = YES;
    req.scene = WXSceneSession;
    
    [WXApi sendReq:req];
}
- (void) penyouquan:(NSString *)str
{

    SendMessageToWXReq* req = [[SendMessageToWXReq alloc] init];
    req.text = str;
    req.bText = YES;
    req.scene = WXSceneTimeline;
    
    [WXApi sendReq:req];
}
-(void)QQliaotian:(NSString *)str
{

    
    //开发者分享的文本内容
    QQApiTextObject *txtObj = [QQApiTextObject objectWithText:str];
    SendMessageToQQReq *req = [SendMessageToQQReq reqWithContent:txtObj];
    //将内容分享到qq
    QQApiSendResultCode sent = [QQApiInterface sendReq:req];
   
       [self handleSendResult:sent];
}

-(void)qqkongjian:(NSString *)str
{
    QQApiTextObject *txtObj = [QQApiTextObject objectWithText:str];
    SendMessageToQQReq *req = [SendMessageToQQReq reqWithContent:txtObj];
    
    //将内容分享到qzone
        QQApiSendResultCode sent = [QQApiInterface SendReqToQZone:req];
    
    [self handleSendResult:sent];

}
- (void)handleSendResult:(QQApiSendResultCode)sendResult
{
    switch (sendResult)
    {
        case EQQAPIAPPNOTREGISTED:
        {
            Elastic *elastic = [[Elastic alloc] init];
       
            break;
        }
        case EQQAPIMESSAGECONTENTINVALID:
        case EQQAPIMESSAGECONTENTNULL:
        case EQQAPIMESSAGETYPEINVALID:
        {
            UIAlertView *msgbox = [[UIAlertView alloc] initWithTitle:@"Error" message:@"发送参数错误" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:nil];
            [msgbox show];
            
            break;
        }
        case EQQAPIQQNOTINSTALLED:
        {
            UIAlertView *msgbox = [[UIAlertView alloc] initWithTitle:@"Error" message:@"未安装手Q" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:nil];
            [msgbox show];
            
            break;
        }
        case EQQAPIQQNOTSUPPORTAPI:
        {
            UIAlertView *msgbox = [[UIAlertView alloc] initWithTitle:@"Error" message:@"API接口不支持" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:nil];
            [msgbox show];
            
            break;
        }
        case EQQAPISENDFAILD:
        {
            UIAlertView *msgbox = [[UIAlertView alloc] initWithTitle:@"Error" message:@"发送失败" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:nil];
            [msgbox show];
            
            break;
        }
        default:
        {
            break;
        }
    }
}
@end
